package swu.cart;

import swu.commodity.Commodity;

import java.sql.SQLException;
import java.util.List;

public class CartService
{
    private CartRepo cartRepo;

    public List<Commodity> getAllFromCart(String username) throws SQLException
    {
        return this.cartRepo.getAllFromCart(username);
    }

    public void addToCartById(List<Commodity> cart, int id) throws SQLException
    {
        this.cartRepo.addToCartById(cart,id);
    }

    public void deleteFromCartById(List<Commodity> cart, int id) throws SQLException
    {
        this.cartRepo.deleteFromCartById(cart,id);
    }

    public void setCartRepo(CartRepo cartRepo)
    {
        this.cartRepo = cartRepo;
    }

    public Boolean isCommodityExists(List<Commodity> cart,int id) throws SQLException
    {
        return this.cartRepo.isCommodityExists(cart,id);
    }
}
